package ca.cbc.msb.mq;

import java.io.Serializable;

import javax.jms.JMSException;
import javax.naming.NamingException;

import ca.cbc.msb.entity.MSBMessage;
import ca.cbc.msb.enums.QueueEnum;

/**
 * Main facility for message delivery. It creates/maintains connections with message server and message queue. And provides methods to send/receive message to/from queue.
 * 
 * @author William Wei
 */
public interface MessageUtil {
	// public void connect();
	
	/**
	 * Send message to queue.
	 * 
	 * @param queueName name of message queue to send message to,  is of type QueueEnum
	 * @param message is of type MSBMessage
	 * @throws NamingException
	 * @throws JMSException
	 */
	public void submitMessage(QueueEnum queueName, Serializable message)
			throws NamingException, JMSException;

	/**
	 * get message from queue. this method may block until getting message.
	 * 
	 * @param queueName name of message queue to get message from,  type QueueEnum 
	 * @return message , type MSBMessage
	 * @throws NamingException
	 * @throws JMSException
	 */
	public MSBMessage getMessage(QueueEnum queueName) throws NamingException,
			JMSException;

	public void commit() throws JMSException;

	public void rollback() throws JMSException;
	
	public void disconnect();

}
